﻿loadJavaScriptFile("../Scripts/jquery-1.7.min.js");
loadJavaScriptFile("../Scripts/UI/minified/jquery.ui.core.min.js");
loadJavaScriptFile("../Scripts/UI/minified/jquery.ui.widget.min.js");
loadJavaScriptFile("../Scripts/UI/minified/jquery.ui.mouse.min.js");
loadJavaScriptFile("../Scripts/UI/minified/jquery.ui.button.min.js");
loadJavaScriptFile("../Scripts/UI/minified/jquery.ui.draggable.min.js");
loadJavaScriptFile("../Scripts/UI/minified/jquery.ui.resizable.min.js");
loadJavaScriptFile("../Scripts/UI/minified/jquery.ui.position.min.js");
loadJavaScriptFile("../Scripts/UI/minified/jquery.ui.dialog.min.js");
loadJavaScriptFile("../Scripts/jquery.metadata.min.js");

function loadJavaScriptFile(jspath) {
    document.write('<script type="text/javascript" src="' + jspath + '"><\/script>');
}

function InitializeDeleteConfirmation() {
    $('#deleteConfirmationDialog').dialog({
        autoOpen: false,
        resizable: false,
        height: 140,
        modal: true,
        buttons: {
            "Delete": function () {
                $(this).dialog("close");
            },
            Cancel: function () {
                $(this).dialog("close");
            }
        }
    });
}

function deleteItem(uniqueID, itemID) {
    var dialogTitle = 'Permanently Delete Item ' + itemID + '?';

    $("#deleteConfirmationDialog").html('<p><span class="ui-icon ui-icon-alert" style="float:left; margin:0 7px 20px 0;"></span>Please click delete to confirm deletion.</p>');

    $("#deleteConfirmationDialog").dialog({
        title: dialogTitle,
        buttons: {
            "Delete": function () { __doPostBack(uniqueID, ''); $(this).dialog("close"); },
            "Cancel": function () { $(this).dialog("close"); }
        }
    });

    $('#deleteConfirmationDialog').dialog('open');
    return false;
}

function ShowError(errorMessage) {
    $(document).ready(function () {
        $("#deleteErrorDialog").text(errorMessage);
        $("#deleteErrorDialog").dialog({
            modal: true,
            buttons: {
                Ok: function () {
                    $(this).dialog("close");
                }
            }
        });
    });
}